<template>
  <div>
    <el-form :inline="true" @submit.native.prevent>
      <el-form-item label="搜索">
        <el-input v-model="search" placeholder="请输入院校名称" @keyup.enter.native="handleSearch" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="table.loading" border :data="table.data">
      <el-table-column label="院校名称" prop="academy_name" />
      <el-table-column label="关注数量" prop="user_relations_count" />
      <el-table-column>
        <template slot-scope="t">
          <el-button type="primary" @click="handleViewUsers(t.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <WrapPagination>
      <el-pagination
        class="pagination"
        :current-page="table.page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="table.size"
        layout="total, prev, pager, next"
        :total="table.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </WrapPagination>
  </div>
</template>

<script>
import { TableMixin } from '../../../components/mixin'
import { followAcademyList } from '../../../api/admin'

export default {
  mixins: [TableMixin],
  data() {
    return {
      search: ''
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.wrapResourceList(followAcademyList, {
        search: this.search
      })
    },
    handleSearch() {
      this.page = 1
      this.getList()
    },
    handleViewUsers(row) {
      this.$router.push({
        name: 'admin-follow-user',
        params: {
          academy_code: row.academy_code
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
